//
//  BezierPathRadius.m
//  KeleAppProject
//
//  Created by Cen Zhou on 2018/1/11.
//  Copyright © 2018年 Cen Zhou. All rights reserved.
//

#import "BezierPathRadius.h"

@implementation BezierPathRadius
+(UIImage *)getImageRadius:(CGFloat)radius andImage:(UIImage *)image{
    
    CGFloat scale = [UIScreen mainScreen].scale;
    UIGraphicsBeginImageContextWithOptions(image.size, NO, scale);
    CGContextRef c = UIGraphicsGetCurrentContext();
    CGRect rect = CGRectMake(0, 0, image.size.width, image.size.height);
    UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:radius];
    CGContextAddPath(c, path.CGPath);
    CGContextClip(c);
    [image drawInRect:rect];
    CGContextDrawPath(c, kCGPathFillStroke);
    UIImage *img = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return img;
}


+ (void)bezierPathWith:(UIView *)view cornerRadius:(CGFloat)radius
{
    UIBezierPath* path = [UIBezierPath bezierPathWithRoundedRect:view.bounds cornerRadius:radius];
    CAShapeLayer* shape = [CAShapeLayer new];
    shape.path = path.CGPath;
    view.layer.mask = shape;
    
}
@end
